<?php
class CultivateLandVo extends SzAbstractMySqlVo
{

    private $userId;
    private $landId;
    private $water_num;
    private $unlock_res;
    private $failed_res;
    private $flowerId;
    private $current_info;

    /**
     * Initialize CultivateLandVo.
     *
     * @param $userId
     * @param $landId
     * @param $water_num
     * @param $unlock_res
     * @param $failed_res
     * @param $flowerId
     * @param $current_info
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return CultivateLandVo
     */
    public function __construct($userId, $landId, $water_num, $unlock_res, $failed_res, $flowerId, $current_info, $isInsert = false) {
        $this->userId = $userId;
        $this->landId = $landId;
        $this->water_num = $water_num;
        $this->unlock_res = $unlock_res;
        $this->failed_res = json_decode($failed_res, true);
        $this->flowerId = $flowerId;
        $this->current_info = json_decode($current_info, true);

        $this->isInsert = $isInsert;
        $this->voClassName = 'CultivateLandVo';
        $this->ormName = 'CultivateLand';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'landId' => $this->getLandId(),
            'water_num' => $this->getWater_num(),
            'unlock_res' => $this->getUnlock_res(),
            'failed_res' => ($needEncode) ? $this->getFailed_res() : $this->getRawFailed_res(),
            'flowerId' => $this->getFlowerId(),
            'current_info' => ($needEncode) ? $this->getCurrent_info() : $this->getRawCurrent_info(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'landId' => $this->getLandId(),
            'water_num' => $this->getWater_num(),
            'unlock_res' => $this->getUnlock_res(),
            'failed_res' => ($needEncode) ? $this->getFailed_res() : $this->getRawFailed_res(),
            'flowerId' => $this->getFlowerId(),
            'current_info' => ($needEncode) ? $this->getCurrent_info() : $this->getRawCurrent_info(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getLandId(),
            $this->getWater_num(),
            $this->getUnlock_res(),
            $this->getFailed_res(),
            $this->getFlowerId(),
            $this->getCurrent_info(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getLandId()
    {
        return $this->landId;
    }

    public function setLandId($val)
    {
        $this->saveColumnStatus(1, $this->landId);
        $this->landId = $val;
    }

    public function getWater_num()
    {
        return $this->water_num;
    }

    public function setWater_num($val)
    {
        $this->saveColumnStatus(2, $this->water_num);
        $this->water_num = $val;
    }

    public function getUnlock_res()
    {
        return $this->unlock_res;
    }

    public function setUnlock_res($val)
    {
        $this->saveColumnStatus(3, $this->unlock_res);
        $this->unlock_res = $val;
    }

    public function getFailed_res()
    {
        return json_encode($this->failed_res);
    }

    public function getRawFailed_res()
    {
        return $this->failed_res;
    }

    public function setFailed_res($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 512) {
            SzLogger::get()->error('[CultivateLandVo] The length of column failed_res exceed the limit, length / limit: ' . $encodedLength . ' / 512');
            throw new SzException(10522, array('CultivateLandVo', '512', $encodedLength));
        } else if ($encodedLength > 460) {
            SzLogger::get()->warn('[CultivateLandVo] The length of column failed_res exceed the warning level, length / limit: ' . $encodedLength . ' / 512');
        }
        $this->saveColumnStatus(4, $this->failed_res);
        $this->failed_res = $val;
    }

    public function getFlowerId()
    {
        return $this->flowerId;
    }

    public function setFlowerId($val)
    {
        $this->saveColumnStatus(5, $this->flowerId);
        $this->flowerId = $val;
    }

    public function getCurrent_info()
    {
        return json_encode($this->current_info);
    }

    public function getRawCurrent_info()
    {
        return $this->current_info;
    }

    public function setCurrent_info($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 512) {
            SzLogger::get()->error('[CultivateLandVo] The length of column current_info exceed the limit, length / limit: ' . $encodedLength . ' / 512');
            throw new SzException(10522, array('CultivateLandVo', '512', $encodedLength));
        } else if ($encodedLength > 460) {
            SzLogger::get()->warn('[CultivateLandVo] The length of column current_info exceed the warning level, length / limit: ' . $encodedLength . ' / 512');
        }
        $this->saveColumnStatus(6, $this->current_info);
        $this->current_info = $val;
    }

    public function updateWater_num($val) {
        $this->saveColumnStatus(2, $this->water_num);
        $this->water_num += $val;
    }

}